package libs.yzx.zaza;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

/**
 * Created by Administrator on 2016/7/28.
 */
public class NotificationActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(new TextView(this));

        new Handler().postDelayed(new Runnable() {
            public void run() {

                Notification.Builder b = new Notification.Builder(NotificationActivity.this);
                b.setContentText("Content Text");
                b.setContentTitle("Content Title");
                b.setTicker("Ticker");
                b.setSmallIcon(R.mipmap.ic_launcher);

                Intent intent = new Intent(NotificationActivity.this, NotificationActivity.this.getClass());
                intent.putExtra("name", "fuck");
                PendingIntent pi = PendingIntent.getActivity(NotificationActivity.this, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT);
                b.setContentIntent(pi);
                //b.setDeleteIntent(pi);

                Notification.InboxStyle box = new Notification.InboxStyle();
                box.addLine("fuck");
                box.addLine("fuck");
                box.addLine("fuck");
                box.addLine("fuck");
                b.setStyle(box);

                Notification.BigPictureStyle bps = new Notification.BigPictureStyle();
                bps.bigPicture(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));
                b.setStyle(bps);

//                RemoteViews rv = new RemoteViews(getPackageName(), 1);
//                rv.setProgressBar(1,100,88,false);


                final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                nm.notify("lala" + System.currentTimeMillis(), 1, b.build());

            }
        }, 2000);
    }

}
